<template>
  <el-container class="layout-container">
    <el-header>
      <div class="header-content">
        <h2>流程审批系统</h2>
        <div class="user-info">
          <span v-if="auth.user">{{ auth.user.fullName }}</span>
          <el-dropdown>
            <el-button type="primary">
              <el-icon><User /></el-icon>
              <el-icon><CaretBottom /></el-icon>
            </el-button>
            <template #dropdown>
              <el-dropdown-menu>
                <el-dropdown-item @click="handleLogout">退出登录</el-dropdown-item>
              </el-dropdown-menu>
            </template>
          </el-dropdown>
        </div>
      </div>
    </el-header>
    
    <el-container>
      <el-aside width="200px">
        <el-menu
          router
          :default-active="$route.path"
          class="el-menu-vertical">
          <el-menu-item index="/process/definitions">
            <el-icon><Document /></el-icon>
            <span>流程定义</span>
          </el-menu-item>
          <el-menu-item index="/process/start">
            <el-icon><Plus /></el-icon>
            <span>发起流程</span>
          </el-menu-item>
          <el-menu-item index="/process/tasks">
            <el-icon><List /></el-icon>
            <span>我的任务</span>
          </el-menu-item>
          <el-menu-item index="/process/my-requests">
            <el-icon><Document /></el-icon>
            <span>我的申请</span>
          </el-menu-item>
        </el-menu>
      </el-aside>
      
      <el-main>
        <router-view></router-view>
      </el-main>
    </el-container>
  </el-container>
</template>

<script setup>
import { User, CaretBottom, Document, Plus, List } from '@element-plus/icons-vue'
import { useRouter } from 'vue-router'
import { ElMessage } from 'element-plus'
import auth from '@/store/auth'

const router = useRouter()

const handleLogout = () => {
  auth.clearUser()
  router.push('/login')
  ElMessage.success('已退出登录')
}
</script>

<style scoped>
.layout-container {
  height: 100vh;
}

.el-header {
  background-color: #fff;
  border-bottom: 1px solid #dcdfe6;
  padding: 0 20px;
}

.header-content {
  height: 100%;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.header-content h2 {
  margin: 0;
}

.user-info {
  display: flex;
  align-items: center;
  gap: 10px;
}

.el-aside {
  background-color: #fff;
  border-right: 1px solid #dcdfe6;
}

.el-menu-vertical {
  border-right: none;
}

.el-main {
  background-color: #f5f7fa;
  padding: 20px;
}
</style> 